libotutil/checksum-utils: Fix memory management
authorMatthew Leeds <matthew.leeds@endlessm.com>
Thu, 29 Mar 2018 06:11:50 +0000 (23:11 -0700)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 29 Mar 2018 13:45:26 +0000 (13:45 +0000)
commit9721be34e161ff5b2d699c52e1add633e8c33347
tree853148522b76386702dd055c25b31f22bf111194
parent2be4631738aaaad27d7689a6e6118c78659b5579
libotutil/checksum-utils: Fix memory management

Ostree uses the OtChecksum data structure as a wrapper around GChecksum
(depending on what libraries are available at compile time). According
to the docs for g_checksum_get_digest(), a GChecksum value can no longer
be updated after that function is called. Ostree enforces this by
setting "initialized" to FALSE after getting the digest, but this leads
to ot_checksum_clear() avoiding freeing any memory, leading to leaks. So
this commit adds a "closed" value that gets set when getting a digest
and checked when updating the value, so the initialized value can be
used only for memory management.

Closes: #1521
Approved by: jlebon
src/libotutil/ot-checksum-utils.c